package baseJava;

import java.lang.ref.WeakReference;

/**
 * Created by kai on 2015/9/17 0017.
 * 强 软 弱 虚  各类引用
 */
public class JavaReferenceShowCase {

    public static void main(String[] args) {
        //test weak reference
        testWeakReference();
    }

    public static void testWeakReference() {
        String abc = new String("abc");
        WeakReference<String> weakReference = new WeakReference<String>(abc);
        System.out.println(weakReference.get());
        //
        abc = null;
        System.out.println(weakReference.get());
        //
        System.gc();
        System.out.println(weakReference.get());
    }
}
